package com.bit.demo.springbookdemo.config;

import com.bit.demo.springbookdemo.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@Slf4j
@ControllerAdvice
@ResponseBody
public class ExceptionAdvice {
    @ExceptionHandler(value=Exception.class)
    public Result handlerException(Exception e){
        log.error("处理异常:",e);
        return Result.error("系统异常");
    }
    @ExceptionHandler(value=Exception.class)
    public Result handlerException(NullPointerException e){
        log.error("处理异常:",e);
        return Result.error("系统异常");
    }

    @ExceptionHandler(value=InterruptedException.class)
    public Result handlerException2(Exception e){
        log.error("处理异常:",e);
        return Result.error("系统异常");
    }
}
